import { director, sys } from 'cc'
export class DataManager {
	private static instance: DataManager = null
	private _diceCount: number = 5

	private constructor() {
		this.init()
	}

	static getInstance(): DataManager {
		if (!this.instance) {
			this.instance = new DataManager()
		}
		return this.instance
	}

	get diceCount(): number {
		return this._diceCount
	}

	set diceCount(value: number) {
		this._diceCount = value
		sys.localStorage.setItem('diceCount', value)
		director.emit('onDiceCountChange', this._diceCount)
	}

	init() {
		this._diceCount = sys.localStorage.getItem('diceCount') || 5
	}
}
